﻿using System;
using System.Windows.Navigation;
using Cimbalino.Phone.Toolkit.Services;
using Microsoft.Practices.ServiceLocation;

namespace DepSoft.Mobile.WP8.FollwIt.Framework
{
    public class CustomUriMapper : UriMapperBase
    {
        public override Uri MapUri(Uri uri)
        {
            if (uri.OriginalString.Equals(Constants.SETTINGSURI, StringComparison.OrdinalIgnoreCase))
            {
                if (!ServiceLocator.Current.GetInstance<IApplicationSettingsService>().Get<bool>("Authenticated", false))
                    uri = new Uri(Constants.LOGINURI, UriKind.Relative);
                else
                    uri = new Uri(Constants.MAINURI, UriKind.Relative);
            }

            return uri;
        }
    }
}
